@extends('front.common.header_bg')

@section('title', '个人中心')

@section('header')
    @parent
@stop

@section('content')

<link href="{{ asset('/js/metisMenu/dist/metisMenu.css') }}" rel="stylesheet"> 
<link href="{{ asset('/css/font-awesome.min.css') }}" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{{ asset('/css/member.css') }}" />
<script src="{{ asset('/js/metisMenu/dist/metisMenu.min.js') }}"></script>
<link href="{{ asset('/js/jcrop/css/jquery.Jcrop.css') }}" rel="stylesheet" >
<script src="{{ asset('/js/jcrop/js/jquery.Jcrop.js') }}"></script>
<script src="{{ asset('/js/member.js') }}"></script>
<style>
<!--
.jcrop-keymgr{
    opacity: 0;
}
-->
</style>
<div style="width:100%;height:20px;background:#f6f6f6"></div>
   <div class="member">
		<div class="big clearfix">
			<div class="user_h">
				<div class="user_h_left fl">
					<div class="fl cp position-relative">
						<input type="file" id="avatarUpload" value="" class="hidden" />
						<div class="show-alert">编辑头像</div>
						<div class="loading user-logo-loading">
                            <i class="icon-spinner icon-spin orange" style="font-size: 40px;"></i>
                        </div>
					</div>
					<div class="fl ml-20" >
						<p style="margin-top:5px">
							<span class="ft-22 cor-2">{{$userinfo->name}}</span>&nbsp;&nbsp;
							<span ><a href="{{url('/member/setting')}}" class="ft-16 cor-3">修改资料</a></span>
						</p>
						<div class="mt-22">
						    <span class="ft-20 cor-1">  {{$userinfo->signature}}</span>
							{{--<img src="{{ asset('/images/front/neweye.png') }}">&nbsp;
							<span class="ft-14 cor-3">人气：</span>
							<span class="ft-20 cor-1">123</span> --}}
						</div>
						<div class="mt-10" style="height:16px;line-height: 16px;">
							<img src="{{ asset('/images/front/member/fan.png') }}">&nbsp;
							<span class="ft-14 cor-3">积分：</span>
							<span class="" style="color:green">{{count($userinfo->score)>0?$userinfo->score->score:0}}</span>&nbsp;
							<img src="{{ asset('/images/front/member/man.png') }}" class="ml-10">&nbsp;
							<span class="ft-14 cor-3">最后登录时间：</span>
							<span class="" style="color:green">{{date('Y-m-d',strtotime($userinfo->last_login_at))}}</span>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
				<div class="fr" style="margin-top:40px;">
					<span class="head_but">
						<a href="{{url('/company')}}" class="head_a">立即求职</a>
					</span>
				</div>
				<div class="clearfix"></div>
			</div>
			<div class="leftsidebar_box sidebar ">
				<ul class="nav nav-sidebar" id="side-menu">
				    @foreach($member_menu as $key=>$menu)
					<li @if($key>0) class="bordertop" @endif>
						<a href="@if(!empty($menu['url'])){{$menu['url']}}@else#@endif" class="menu-title">{{$menu['title']}}@if(!empty($menu['items']))<span class="fa arrow"></span>@endif</a>
						@if(!empty($menu['items']))
						<ul class="nav nav-second-level">
    						@foreach($menu['items'] as $it)
							<li><a href="{{$it['url']}}">{{$it['title']}}</a></li>
    						@endforeach
						</ul>
						@endif
					</li>
					@endforeach
				</ul>
			</div>
	    @yield('rightcontainer')
	    </div>
	</div>
	<div class="clearfix"></div>

    <div id="uploadlogo" class="logocontainer dn">
        <div class="logosection">
           <form action="#" method="post" onSubmit="return checkCoords();">
            <input type="hidden" id="logoimg" name="img" />
            <input type="hidden" id="x" name="x" />
            <input type="hidden" id="y" name="y" />
            <input type="hidden" id="w" name="w" />
            <input type="hidden" id="h" name="h" />
            <div class="from-row imgchoose clearfix" style="display:none">
                <div class="float-l" style="width: 400px"><img id="target"  src=""  class="preview"/></div>
                <div class="float-l" style="width:200px;margin-left:20px;">
                    <div style="width:120px;height:120px;margin-left:20px;overflow:hidden;">
                         <img class="preview" id="preview2" src=""  width="120"/>
                    </div>
                </div>
            </div>
            <div class="from-row imgchoose" style="display:none">
                <button type="button" id="avatar_submit" class="avatar_submit">保存</button>
            </div>
           </form>
        </div>
    </div>

</div>
<script type="text/javascript">
    function updateLogo(){
        layer.open({
            type: 1,
            area: ['870px', '500px'],
            title:['上传头像', 'font-size:18px;'],
            skin: 'layui-layer-rim',
            content: $('#uploadlogo')
        });
    }
    $(function() {
        
    	avatarLogo('{{ $userinfo->middle_logo }}','{{csrf_token()}}',"{{ asset('/js/uploadify/uploadify.swf') }}");
        $("#avatar_submit").click(function(){
            var logoimg = $("#logoimg").val();
            var x = $("#x").val();
            var y = $("#y").val();
            var w = $("#w").val();
            var h = $("#h").val();
            if( checkCoords() ){
                $.ajax({
                    type:'post',
                    cache:'false',
                    url: "/upload/logo",
                    data:'img='+logoimg+'&x='+x+'&y='+y+'&w='+w+'&h='+h+'&_token='+'{{ csrf_token() }}'+'&uid'+'{{ $userinfo->id }}',
                    dataType:'json',
                    success: function(data){
                        if( data.status == 'success'){
//                             $('#avatarUpload-button').css('background-image','{{ $userinfo->middle_logo."?v=".time() }}');
                        	avatarLogo('{{ $userinfo->middle_logo."?v=".time() }}','{{csrf_token()}}',"{{ asset('/js/uploadify/uploadify.swf') }}");
                        	$(".layui-layer-close").click();
                        }
                    }
                });
            }
        });
        function avatarLogo(imgurl,token,swfurl){
        	$("#avatarUpload").uploadify({
            	'onInit': function () {                        //载入时触发，将flash设置到最小
                    $("#avatarUpload-queue").hide();
                },
                'formData'     : {
                    'fileField':'upfile',
                    '_token':token,
                    'type':'up'
                },
                'width'				: 120,
                'height'			: 120,
                'removeCompleted'	: false,
                'swf'				: swfurl,
                "fileObjName"       : "upfile",
                "buttonText"        : "请选择图片",
                "buttonImage"       : imgurl,
                'uploader'			: '/upload/logo',
                'removeTimeout'	    : 1,
                'auto'				: true,
                'fileTypeExts'		: '*.gif; *.jpg; *.jpeg; *.png;',
                'fileSizeLimit'		: '1024KB',
                'onSelect': function(e, queueId, fileObj){
					$('.user-logo-loading').show();
                },
                'onUploadSuccess' : function(file, data, response) {
                	$('.user-logo-loading').hide();
                    var data = eval('(' + data + ')');
                    if (data.status == 'success') {
                    	updateLogo();
                        $(".imgchoose").show();
                        $("#logoimg").val( data.attach );
                        $(".preview").attr("src",'');
                        $(".preview").attr("src",data.newurl);
                        logocrop("target");
                        $(".jcrop-holder").find('img').attr("src",'');
                        $(".jcrop-holder").find('img').attr("src",data.newurl);
                    }else{
                        layer.open({
                            title: '提示',
                            content: data.msg
                        });
                        return false;
                    }
                }
            });
        };
        //头像裁剪
    });
    function checkCoords(){
        if (parseInt($('#w').val())) {
            return true;
        };
        layer.open({
            title: '提示',
            content: '请先选择要裁剪的区域后，再提交。'
        });
        return false;
    };

</script>
@yield('otherinfo')
@stop

@section('footer')
    @parent
@stop

